﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;
using CustomsSystem.BLL;
using CustomsSystem.Model;

namespace WEB.sheetInfo
{
    public partial class sheetContainerNoInput : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindCodeData(ddlContainer, "unitType");
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            AddContainerNo();
        }

        public string AddContainerNo()
        {
            string str = tbRes.Text;

            foreach (Control c in panelAdd.Controls)
            {
                if (c is TextBox)
                {
                    TextBox tb = c as TextBox;
                    if (tb.Text != "")
                    {
                        if (str == "") { str += string.Format("{0}({1})", tb.Text,ddlContainer.SelectedItem.Text); }
                        else { str += string.Format(",{0}({1})", tb.Text, ddlContainer.SelectedItem.Text); }
                    }
                    tb.Text = "";
                }
            }
            tbRes.Text = str;
            return str;
        }

        /// <summary>
        /// 获取制定代码类型绑定到控件上
        /// </summary>
        /// <param name="ddl"></param>
        private void BindCodeData(DropDownList ddl, string codeType)
        {
            CodeManage codeBll = new CodeManage();
            List<Info_code> codeModels = codeBll.GetModelList("codeType='" + codeType + "'");
            foreach (Info_code aCode in codeModels)
            {
                ddl.Items.Add(new ListItem(aCode.codeName, aCode.codeID.ToString()));
            }
        }

        protected void TextBox_TextChanged(object sender, EventArgs e)
        {
        }
    }
}